package csel.model.skills;

import csel.model.Direction;
import csel.model.Tile;
import csel.model.entity.Character;
import csel.model.entity.Entity;
import csel.model.CharacterStats;

import csel.model.items.KillerTrap; //testing

public class RemoveTrap extends RangedActiveSkill
{
	private static final long serialVersionUID = 5L;
	Character c;
	public RemoveTrap(Character owner)
	{
		super(owner);
		c = owner;
		setName("default");
		setDescription("attempt to remove it");
		setAllocatedPoints(1);
	}
	
	public void use(Direction d, Tile t)
	{
		double chanceOfSuccess = 1.0 - ((1.0)/(Math.pow(2, getPointsAllocated()/1.99)));
		
		c.setCharacterStat(CharacterStats.ManaUsed, (c.getCharacterStat(CharacterStats.ManaUsed)+4));
		double roll = Math.random();
		
		/* HACK */
		if(roll <= chanceOfSuccess && c.getCharacterStat(CharacterStats.CurrentMana) >= 4)
		{
			/* HACK *//* HACK *//* HACK *//* HACK *//* HACK *//* HACK *//* HACK */
			if(t != null && t.getItem() instanceof KillerTrap)
			{
				t.setItem(null);
			}
		}
		
	}
	public void use(Entity e)
	{
		//TODO
	}
}
